package WaiBao;

import java.util.Arrays;

public class LiYuJie {
    public static void main(String[] args) {
        String[] name = {"李志忠(班长)", "黄俊凯(副班长)", "小李(学习委员)", "李小可(体育委员)", "李现", "王子文", "王迅", "流星", "李勋", "高见鸿", "时光", "储殷",
                "余量", "于亮", "戴天", "王猛", "张博伟", "李志远", "淑华", "高磊", "王婷", "张萌", "李开智", "姚精良", "王志文", "韩信", "刘翔", "苏炳添",
                "林丹", "李宇杰(学生)"};//考生本人:李宇杰(学生)
        int[] age = {22, 21, 19, 19, 18, 19, 21, 22, 19,20, 18, 18, 20, 21, 21, 19, 18, 19, 21, 20, 19, 19, 20, 20, 22, 18, 20, 22, 20, 20};//考生年龄20

        double[] yuliang1 = {74, 90, 88, 79, 77, 75, 75, 69, 73, 80, 64, 73, 71, 72, 95, 78, 66, 80, 76, 58, 92, 87, 75, 88, 75, 75, 84, 92, 86, 96};
        double[] yuliang2 = {88, 77, 84, 71, 89, 74, 73, 80, 70, 71, 85, 90, 85, 74, 84, 71, 74, 89, 64, 55, 87, 71, 84, 85, 82, 85, 81, 94, 75, 94};
        double[] yuliang3 = {77, 84, 74, 87, 71, 61, 74, 89, 84, 60, 63, 81, 75, 75, 95, 68, 64, 69, 96, 93, 92, 81, 95, 75, 79, 84, 77, 66, 60, 93};

        double chuying1;//代表每个学生的总分
        double chuying2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            chuying1 = yuliang1[i] +yuliang2[i] +yuliang3[i];
//            chuying2 = ( chuying1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" +chuying1);
//            System.out.println(name[i] + "的平均分为:" +chuying2);
//        }

        double zijie1 = 0,zijie2 = 0;
        double[] tiaodong = new double[30];
//        for (int i = 0; i < 30; i++) {
//            zijie1 = yuliang1[i] +yuliang2[i] + yuliang3[i];
//            zijie2= (zijie1 * 1.0) / 3;
//            tiaodong[i] = zijie2;
//        }
//
//        for (int i = 0; i <tiaodong.length - 1; i++) {
//            for (int j = 0; j <tiaodong.length - i - 1; j++) {
//                if (tiaodong[j] < tiaodong [j + 1]) {
//                    double tep =tiaodong[j];
//                    tiaodong[j] =tiaodong[j + 1];
//                    tiaodong[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(tiaodong[i]);
//        }


        double zhiwei1 = 0,zhiwei2 = 0,zhiwei3 = 0;//计算每门课的平均分
        double longkui1 = 0,longkui2 = 0, longkui3 = 0;//计算每门课标准差
        double maomao1 = 0,maomao2 = 0,maomao3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < yuliang1.length; i++) {
            sum2+= yuliang1[i];
        }
        zhiwei1 = (sum2*1.0)/30;
        System.out.println("生物化学的班级平均分为:"+zhiwei1);
        double Sum = 0;
        for (int i = 0; i < yuliang2.length; i++) {
            Sum+= yuliang2[i];
        }
        zhiwei2 = (Sum*1.0)/30;
        System.out.println("微生物学的班级平均分为:"+zhiwei2);
        double sum = 0;
        for (int i = 0; i < yuliang3.length; i++) {
            sum+= yuliang3[i];
        }
        zhiwei3 = (sum*1.0)/30;
        System.out.println("人体组织解剖学的班级平均分为:"+ zhiwei3);


////
        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i <  yuliang1.length; i++) {
            c1+= ( yuliang1[i] -zhiwei1)*( yuliang1[i] -zhiwei1);
        }
        longkui1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:"+longkui1);

        for (int i = 0; i < yuliang2.length; i++) {
            c2+= ( yuliang2[i] -zhiwei2)*( yuliang2[i] - zhiwei2);
        }
        longkui2 = Math.sqrt(c2*1.0/30);
        System.out.println("微生物学的班级标准差为:"+longkui2);

        for (int i = 0; i <  yuliang3.length; i++) {
            c3+= ( yuliang3[i] -zhiwei3)*( yuliang3[i] -zhiwei3);
        }
        longkui3 = Math.sqrt(c3*1.0/30);
        System.out.println("人体组织解剖学的班级标准差为:"+longkui3);
//////
////////
        Arrays.sort( yuliang1);
        Arrays.sort( yuliang2);
        Arrays.sort( yuliang3);
        maomao1 =( yuliang1[14]+ yuliang1[15])*1.0/2;
        maomao2 =( yuliang2[14]+ yuliang2[15])*1.0/2;
        maomao3 =( yuliang3[14]+ yuliang3[15])*1.0/2;
        System.out.println("生物化学的中位数为:"+maomao1);
        System.out.println("微生物学的中位数为:"+maomao2);
        System.out.println("人体组织解剖学的中位数为:"+maomao3);





    }
}
